<template>
    <div class="pageContainer">
        <div class="treeTable">
            <div style="flex:1;display:flex;">
                <div style="width:900px;">
                    <div style="margin:20px 20px;">
                        <span v-if="listPrinter.length > 0">识别到打印机：{{listPrinter[0].name}}</span>
                        ,当前打印机设置
                    </div>
                    
                    <el-form :inline="true">
                        <CText form v-model="mm.width_mm" title="标签宽度"></CText>
                        <CText form v-model="mm.height_mm" title="标签高度"></CText>
                        <CText form v-model="mm.speed" title="打印速度"></CText>
                        <CText form v-model="mm.density" title="打印浓度"></CText>
                        <CText form v-model="mm.sensor" title="打印种类"></CText>
                        <CText form v-model="mm.gap_height" title="间隙高度"></CText>
                        <CText form v-model="mm.gap_offset" title="间隙偏移"></CText>
                        <CText form v-model="mm.x" title="坐标x"></CText>
                        <CText form v-model="mm.y" title="坐标y"></CText>
                        <CText form v-model="mm.height" title="条码高度"></CText>
                        <CText form v-model="mm.readable" title="条码可读性"></CText>
                        <CText form v-model="mm.rotation" title="条码旋转"></CText>
                        <CText form v-model="mm.narrow" title="窄元线条宽度"></CText>
                        <CText form v-model="mm.wide" title="宽元件宽度"></CText>
                    </el-form>
                </div>
                <div>
                    <div style="margin:20px 20px;">调整打印位置</div>
                    <el-form :inline="true">
                        <CBtn @click="movedown">向下移动10mm</CBtn>
                        <CBtn @click="moveup">向上移动10mm</CBtn>
                        <CBtn @click="printtest">打印测试页</CBtn>
                    </el-form>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import pagingMixin from '@/mixin/pagingMixin'
import tscDriver from "@/utils/tscDriver";
export default {
    mixins: [pagingMixin],
    data() {
        return {
            model: "sys",
            table: "SysConfig",
            mm: {  },
            listPrinter: []
        }
    },
    created() {
        //安装驱动到当前组件
        tscDriver.setup(this);
        this.init();
    },
    methods: {
        init() {
            this.$sys.getById(this.model, this.table, {id: "printer-config"}).then(res => {
                this.mm = JSON.parse(res.data.configVal);
            })
            tscDriver.getPrinterList();
        },
        movedown() {
            this.mm.height_mm = Number(this.mm.height_mm) + 2;
            tscDriver.resetprint(this.mm);
        },
        moveup() {
            this.mm.height_mm = Number(this.mm.height_mm) - 2;
            tscDriver.resetprint(this.mm);
        },
        printtest() {
            this.$sys.getById(this.model, this.table, {id: "printer-config"}).then(res => {
                this.mm = JSON.parse(res.data.configVal);
                tscDriver.printCode("123456789012345678901234567890123456",this.mm);
            })
            
        }
    }
}
</script>

<style lang="scss" scoped></style>